/* promise形式封装小程序API */
export const getSetting=()=>{
    return new Promise((resole,reject)=>{
        wx.getSetting({
            success: (result)=>{
                resole(result)
            },
            fail: (err)=>{
                reject(err)
            }
        });
    })
}

export const openSetting=()=>{
    return new Promise((resole,reject)=>{
        wx.openSetting({
            success: (result)=>{
                resole(result)
            },
            fail: (err)=>{
                reject(err)
            }
        });
    })
}

export const chooseAddress=()=>{
    return new Promise((resole,reject)=>{
        wx.chooseAddress({
            success: (result)=>{
                resole(result)
            },
            fail: (err)=>{
                reject(err)
            }
        });
    })
}

export const showModal=(content)=>{
    return new Promise((resole,reject)=>{
        wx.showModal({
            title: '提示',
            content: content,
            showCancel: true,
            cancelText: '取消',
            cancelColor: '#000000',
            confirmText: '确定',
            confirmColor: '#3CC51F',
            success: (result) => {
                resole(result)
            },
            fail: (err) => reject(err)
        });
    })
}

export const showToast=(title)=>{
    return new Promise((resole,reject)=>{
        wx.showToast({
            title: title,
            icon: 'none',
            duration: 1000,
            mask: false,
            success: (result)=>{
                resole(result)
            },
            fail: (err)=>{
                reject(err)
            }
        });
    })
}

export const login=()=>{
    return new Promise((resole,reject)=>{
        wx.login({
            timeout:10000,
            success: (result)=>{
                resole(result)
            },
            fail: (err)=>{
                reject(err)
            }
        });
    })
}
/* timeStamp: '',
nonceStr: '',
package: '',
signType: '',
paySign: '', */
export const requestPayment=(pay)=>{
    return new Promise((resole,reject)=>{
        wx.requestPayment({
            ...pay,
            success: (result)=>{
                resole(result)
            },
            fail: ()=>{
                reject(err)
            }
        });
    })
}